import socket
from SipConf import SipConf
import sys


class SocketClient:
    host = 'localhost'
    port = 9002
    sock = None
    
    def __init__(self):
        self.host = SipConf.QUEUE_HOST
        self.port = SipConf.QUEUE_PORT
        self.connect()
    
    def connect(self): 
        try:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)   
            self.sock.connect((self.host, self.port))   
        except:
            print_exc(file = sys.stdout)
            print 'SocketClient con err'
            sys.stdout.flush()
    
    def send(self,msg):
        self.sock.send(msg) 
        return self.sock.recv(512)
    
    def close(self):
        return self.sock.close()
    
if __name__ == '__main__':   
    s = SocketClient()
    print s.send('sdfsdfsdf\n')
    s.close()